home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / video / fly8111-.000 / fly8111- / fly8 / ochute.c < prev    next >
C/C++ Source or Header  |  1979-12-31  |  2KB  |  98 lines

  1. /* --------------------------------- ochute.c ------------------------------- */
  2.  
  3. /* This is part of the flight simulator 'fly8'.
  4.  * Author: Eyal Lebedinsky (eyal@ise.canberra.edu.au).
  5. */
  6.  
  7. /* object: parachute.
  8. */
  9.  
  10. #include "fly.h"
  11.  
  12.  
  13. static SHAPE shape_chute = {
  14.     0,
  15.     0,
  16.     SH_G|SH_LOCALSIM,
  17.     200*1000L,    /* weight */
  18.     0        /* drag */
  19. };
  20.  
  21. LOCAL_FUNC int FAR
  22. create_chute (OBJECT *p)
  23. {
  24.     if (!st.owner)
  25.         return (1);
  26.  
  27.     p->color = CC_GREEN;
  28.     p->time = FOREVER;        /* let them land */
  29.     p->flags |= F_VISIBLE;
  30.     p->speed = st.owner->speed;
  31.     p->owner   = st.owner;        /* point at plane */
  32.     p->ownerid = st.owner->id;
  33.  
  34.     st.owner->owner = p;        /* it owns the plane */
  35.     st.owner->ownerid = p->id;
  36.     if (st.owner->flags & F_EXPORTED)
  37.         p->flags |= F_EXPORTED;
  38.  
  39.     Vcopy (p->V, st.owner->V);
  40.     LVcopy (p->R, st.owner->R);
  41.     p->da[Z] = VD90/18;
  42.     Mident (p->T);
  43.  
  44.     return (0);
  45. }
  46.  
  47. extern void FAR
  48. dynamics_chute (OBJECT *p, int interval)
  49. {
  50.     int    force;
  51.  
  52.     if (p->R[Z] <= 0) {
  53.         p->R[Z] = 0;
  54.         p->V[Z] = 0;
  55.         if (p->ownerid != p->owner->id &&    /* owner gone */
  56.             !(p->flags & F_IMPORTED)) {        /* native */
  57.             if (p->gpflags & GPF_PILOT) {    /* not a drone */
  58.                 CC->gpflags |= GPF_PILOT;
  59.                 CC->flags &= ~F_STEALTH;
  60.                 CC->flags |= F_MOD;
  61.             }
  62.             p->flags |= F_DEL|F_MOD;
  63.         }
  64.         return;
  65.     }
  66.     p->V[X] -= TADJ(p->V[X]/2);
  67.     p->V[Y] -= TADJ(p->V[Y]/2);
  68.  
  69.     p->da[Z] -= TADJ(p->da[Z]/2);
  70.  
  71.     force = -p->V[Z]*2 - GACC;    /* stabilize at 5 m/sec */
  72.                     /* too fast but looks OK */
  73.     p->V[Z] += TADJ (force);
  74.     p->speed = ihypot3d (p->V);
  75.  
  76.     if (p->da[X] || p->da[Y] || p->da[Z]) {
  77.         p->a[X] += TADJ(p->da[X])*VONE;
  78.         p->a[Y] += TADJ(p->da[Y])*VONE;
  79.         p->a[Z] += TADJ(p->da[Z])*VONE;
  80.         Mobj (p);
  81.     }
  82.  
  83.     object_update (p, interval);
  84. }
  85.  
  86. BODY FAR BoChute = {
  87.     0,
  88.     0,
  89.     "CHUTE",
  90.     &shape_chute,
  91.     gen_read,
  92.     gen_term,
  93.     create_chute,
  94.     gen_delete,
  95.     dynamics_chute,
  96.     gen_hit
  97. };
  98.